const { createProxyMiddleware } = require('http-proxy-middleware')

 
module.exports = function (app) {

    app.use(
        createProxyMiddleware("/jian", {
            target: 'https://www.jianshu.com/asimov',
            changeOrigin: true,
            ws: true,
            pathRewrite: {   '^/jian': '' },
            secure: true,
        })
    );
    app.use(
        createProxyMiddleware("/zhi",{
            target: 'https://news-at.zhihu.com/api/4',
            changeOrigin: true,
            ws: true,
            pathRewrite: {   '^/zhi': '' },
            secure: true,
        })
        
    );

    app.use(
        createProxyMiddleware("/douban",{
            target: 'https://movie.douban.com',
            changeOrigin: true,
            ws: true,
            pathRewrite: {   '^/douban': '' },
            secure: true,
        })
    );

    // https://market.douban.com/api/v2/market/specials?dt_market_source=pc&start=0&count=5
    app.use(
        createProxyMiddleware("/doubanM",{
            target: 'http://localhost:3000',
            changeOrigin: true,
            ws: true,
            pathRewrite: {   '^/doubanM': '' },
            secure: false,
        })
    );
}

